<template>
  <section id="home" class="hero">
    <div class="hero-background">
      <div class="hero-pattern"></div>
      <a-carousel class="hero-carousel" autoplay :dots="true" effect="fade">
        <div class="carousel-slide slide-1"></div>
        <div class="carousel-slide slide-2"></div>
        <div class="carousel-slide slide-3"></div>
        <div class="carousel-slide slide-4"></div>
      </a-carousel>
    </div>

    <div class="hero-content">
      <div class="hero-text animate-fade-in">
        <h1 class="hero-title">
          <span class="hero-title-main">前端开发工程师</span>
          <span class="hero-title-sub"><TypewriterText :text="typewriterTexts" :speed="100" /></span>
        </h1>
        <p class="hero-description">
          专注于Vue.js、TypeScript和现代前端技术栈，致力于创造优雅的用户体验和高效的Web应用
        </p>
        <div class="hero-stats animate-slide-up">
          <div class="stat-item">
            <span class="stat-number"><AnimatedCounter :target="3" suffix="年" /></span>
            <span class="stat-label">开发经验</span>
          </div>
          <div class="stat-item">
            <span class="stat-number"><AnimatedCounter :target="50" :suffix="'+'" /></span>
            <span class="stat-label">完成项目</span>
          </div>
          <div class="stat-item">
            <span class="stat-number"><AnimatedCounter :target="100" :suffix="'%'" /></span>
            <span class="stat-label">客户满意度</span>
          </div>
        </div>
      </div>

      <div class="hero-actions animate-slide-up">
        <a-button
          type="primary"
          size="large"
          class="hero-btn"
          @click="scrollToProjects"
        >
          <template #icon><EyeOutlined /></template>
          查看作品
        </a-button>
        <a-button
          size="large"
          class="hero-btn-secondary"
          @click="scrollToContact"
        >
          <template #icon><MessageOutlined /></template>
          联系我
        </a-button>
      </div>

      <div class="hero-scroll-indicator">
        <div class="scroll-mouse">
          <div class="scroll-wheel"></div>
        </div>
        <span class="scroll-text">向下滚动</span>
      </div>
    </div>
  </section>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { EyeOutlined, MessageOutlined } from '@ant-design/icons-vue'
import { Carousel } from 'ant-design-vue'
import TypewriterText from './TypewriterText.vue'
import AnimatedCounter from './AnimatedCounter.vue'

const typewriterTexts = [
  'Vue.js 专家',
  'TypeScript 开发者',
  '用户体验设计师',
  '技术解决方案架构师'
]

const scrollToProjects = () => {
  const element = document.getElementById('projects')
  if (element) {
    element.scrollIntoView({ behavior: 'smooth' })
  }
}

const scrollToContact = () => {
  const element = document.getElementById('contact')
  if (element) {
    element.scrollIntoView({ behavior: 'smooth' })
  }
}
</script>

<style scoped>
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 1;
}

.hero-pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
}

.hero-carousel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100% !important;
}

.carousel-slide {
  height: 100vh;
  position: relative;
}

.slide-1 {
  background: url(https://picsum.photos/id/1/1900/920?) no-repeat center center/cover;
}

.slide-2 {
  background: url(https://picsum.photos/id/2/1900/920) no-repeat center center/cover;

}

.slide-3 {
  background: url(https://picsum.photos/id/3/1900/920) no-repeat center center/cover;
}

.slide-4 {
  background: url(https://picsum.photos/id/4/1900/920) no-repeat center center/cover;
}

.hero-carousel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.7) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.8) 0%, transparent 50%),
    radial-gradient(circle, rgba(255, 255, 255, 0.8) 1px, transparent 1px);
  background-size: auto, auto, 50px 50px;
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: white;
  max-width: 800px;
  padding: 0 2rem;
}

.hero-title {
  margin-bottom: 1.5rem;
}

.hero-title-main {
  display: block;
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(45deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-title-sub {
  display: block;
  font-size: 1.5rem;
  font-weight: 300;
  opacity: 0.9;
  min-height: 2rem;
}

.hero-description {
  font-size: 1.2rem;
  line-height: 1.6;
  margin-bottom: 3rem;
  opacity: 0.9;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 4rem;
  margin-bottom: 3rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 4rem;
}

.hero-btn {
  min-width: 150px;
  height: 50px;
  font-size: 1rem;
  border-radius: 25px;
  transition: all 0.3s ease;
}

.hero-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.hero-btn-secondary {
  background: transparent;
  border: 2px solid white;
  color: white;
  min-width: 150px;
  height: 50px;
  font-size: 1rem;
  border-radius: 25px;
  transition: all 0.3s ease;
}

.hero-btn-secondary:hover {
  background: white;
  color: var(--primary-color);
  transform: translateY(-2px);
}

.hero-scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: bounce 2s infinite;
}

.scroll-mouse {
  width: 30px;
  height: 50px;
  border: 2px solid white;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  padding-top: 8px;
  margin-bottom: 0.5rem;
}

.scroll-wheel {
  width: 4px;
  height: 8px;
  background: white;
  border-radius: 2px;
  animation: scroll-wheel 2s infinite;
}

.scroll-text {
  font-size: 0.8rem;
  opacity: 0.7;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  40% {
    transform: translateX(-50%) translateY(-10px);
  }
  60% {
    transform: translateX(-50%) translateY(-5px);
  }
}

@keyframes scroll-wheel {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(20px);
  }
}

.animate-fade-in {
  animation: fadeInUp 1s ease-out;
}

.animate-slide-up {
  animation: slideUp 1s ease-out 0.3s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .hero-title-main {
    font-size: 2.5rem;
  }

  .hero-title-sub {
    font-size: 1.2rem;
  }

  .hero-description {
    font-size: 1rem;
  }

  .hero-stats {
    gap: 2rem;
  }

  .stat-number {
    font-size: 2rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }
}
</style>